package com.glorysoft.sunnypda.ui.unlock

import com.glorysoft.sunnypda.base.BaseViewModel
import com.glorysoft.sunnypda.entity.ui.CallObserveBean
import com.glorysoft.sunnypda.model.EqpRepository
import com.glorysoft.sunnypda.model.LoginRepository
import com.google.gson.JsonObject

/**
 * FileName: UnLockViewModel
 * Author: XJH
 * Date: 2022/1/7 17:27
 * Description:
 * History:
 */
class UnLockViewModel : BaseViewModel() {

    val eqpRepository : EqpRepository = EqpRepository()

    fun getEqpInfo(eqp : String){
        val map = JsonObject()
        map.addProperty("EQPID",eqp)
        launchOnlyResult({
            val eqpInfo = eqpRepository.getEqpInfo(map)
            defUI.callObserve.value = CallObserveBean(0,eqpInfo)
        })

    }

    fun submitLock(isLock : Boolean,eqp : String){
        val map = JsonObject()
        map.addProperty("EQPID",eqp)
        map.addProperty("ACTIONOP",(if(isLock) 0 else 1))
        launchOnlyResult({
            eqpRepository.getEqpUnLock(map)
            defUI.callObserve.value = CallObserveBean(1,"")
        })
    }










}